import * as axios from '@/api/user.js'
import { withMsg2 } from '@/utils/request.js'

export default {
  // 模块必须有这句话
  namespaced: true,
  state: {
    userinfo: {
      name: '请登录'
    }
  },
  mutations: {
    setinfo(state, info) {
      state.userinfo = info
    }
  },
  actions: {
    async getinfo(context) {
      const { data: res } = await withMsg2(axios.userinfo())
      context.commit('setinfo', res.data)
    }
  }
}
